import { useState } from 'react';

import { ModalId } from '@/shared/lib/modals';

export const useModal = () => {
  const [id, setId] = useState<ModalId | null>(null);
  const [data, setData] = useState<any>(null);

  const openModal = (idLocal: ModalId, dataLocal?: any) => {
    setId(idLocal);
    setData(dataLocal);
  };

  const closeModal = () => {
    setId(null);
    setData(null);
  };

  return {
    openModal,
    closeModal,
    id,
    data,
  };
};
